<?php

/**
 * Menashop
 *
 * LICENSE
 *
 * This source file is subject to the license that is bundled
 * with this project in the file LICENSE.txt
 *
 * @category   Zend
 * @package    Admin_Model
 * @subpackage FormShipment
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 * @version    1.0.0
 * @since      File available since Release 1.0.0
 */

/**
 * The form for shipment
 * 
 * @category   Zend
 * @package    Admin_Model
 * @subpackage FromShipment
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 */
class Admin_Model_FormShipment extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');

        $id = new Zend_Form_Element_Hidden('id');
        $id->removeDecorator('label');
        $id->removeDecorator('htmlTag');
        $id->removeDecorator('Errors');
        $this->addElement($id);

        $quantity = new Zend_Form_Element_Text('quantity');
        $quantity->setRequired(true);
        $quantity->addValidator('Int');
        $quantity->addErrorMessage('Please provide quanity');
        $quantity->removeDecorator('label');
        $quantity->removeDecorator('htmlTag');
        $quantity->removeDecorator('Errors');
        $this->addElement($quantity);

        $cost = new Zend_Form_Element_Text('cost');
        $cost->setRequired(true);
        $cost->addValidator(new Zend_Validate_Float(array('locale' => 'en_us')));
        $cost->addErrorMessage('Please provide cost');
        $cost->removeDecorator('label');
        $cost->removeDecorator('htmlTag');
        $cost->removeDecorator('Errors');
        $this->addElement($cost);

        $toName = new Zend_Form_Element_Text('to_name');
        $toName->setRequired(true);
        $toName->addValidator('StringLength', false, array(2, 50));
        $toName->addErrorMessage('Please provide customer name');
        $toName->removeDecorator('label');
        $toName->removeDecorator('htmlTag');
        $toName->removeDecorator('Errors');
        $this->addElement($toName);

        $status = new Zend_Form_Element_Select('status');
        $shipmentStatusModel = new Admin_Model_ShipmentStatus();
        $shipmentStatuses = $shipmentStatusModel->fetchAllPairs();
        foreach ($shipmentStatuses as $key => $value) {
            $status->addMultiOption($key, $value);
        }
        $status->setRequired(true);
        $status->addErrorMessage('Please provide status');
        $status->removeDecorator('label');
        $status->removeDecorator('htmlTag');
        $status->removeDecorator('Errors');
        $this->addElement($status);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $submit->removeDecorator('DtDdWrapper');
        $this->addElement($submit);

        $this->setDecorators(array(array('ViewScript', array('viewScript' => '_form_shipment.phtml'))));
    }

}

